package com.lyw.config.datasource;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
public class MyDataSource {

  @Bean
  @ConfigurationProperties(prefix = "spring.datasource")
  public DataSource dataSource() throws SQLException {
    DruidDataSource druidDataSource = new DruidDataSource();
    //开启监控，打开防火墙
    //druidDataSource.setFilters("stat,wall");
    return druidDataSource;
  }
}
